// todo : 应用颜色
import 'package:flutter/material.dart';
import 'package:flex_color_scheme/flex_color_scheme.dart';

class AppColors {
  // 主色调
  static const Color primaryColor = Colors.indigo;
  static const Color secondaryColor = Colors.indigo;
  static const Color tertiaryColor = Colors.indigoAccent;

  // 中性色
  static const Color neutral0 = Color(0xFFFFFFFF);
  static const Color neutral10 = Color(0xFFFAFBFC);
  static const Color neutral20 = Color(0xFFF4F6F8);
  static const Color neutral30 = Color(0xFFDFE3E8);
  static const Color neutral50 = Color(0xFF919EAB);
  static const Color neutral70 = Color(0xFF454F5B);
  static const Color neutral90 = Color(0xFF161C24);
  static const Color neutral100 = Color(0xFF000000);

  // 语义色
  static const Color success = Color(0xFF4CAF50);
  static const Color warning = Color(0xFFFFC107);
  static const Color error = Color(0xFFF44336);
  static const Color info = Color(0xFF29B6F6);

  // 动态颜色获取
  static Color dynamicSurface(BuildContext context) =>
      Theme.of(context).colorScheme.surface;

  static Color dynamicOnSurface(BuildContext context) =>
      Theme.of(context).colorScheme.onSurface;

  // 动态颜色生成(不使用 FlexColorScheme)
  static ColorScheme lightColorScheme() => ColorScheme.fromSeed(
        seedColor: primaryColor,
        brightness: Brightness.light,
        secondary: secondaryColor,
        tertiary: tertiaryColor,
      );

  static ColorScheme darkColorScheme() => ColorScheme.fromSeed(
        seedColor: primaryColor,
        brightness: Brightness.dark,
        secondary: secondaryColor,
        tertiary: tertiaryColor,
      );

  // 使用 FlexColorScheme 创建动态色彩方案
  static ColorScheme lightFlexColorScheme() {
    return FlexColorScheme.light(
      primary: primaryColor,
      secondary: secondaryColor,
      tertiary: tertiaryColor,
      surface: neutral0,
      background: neutral20,
      error: error,
      onPrimary: neutral0,
      onSecondary: neutral0,
      onTertiary: neutral0,
      onSurface: neutral70,
      onBackground: neutral70,
      onError: neutral100,
    ).toScheme;
  }

  static ColorScheme darkFlexColorScheme() {
    return FlexColorScheme.dark(
      primary: primaryColor,
      secondary: secondaryColor,
      tertiary: tertiaryColor,
      surface: neutral90,
      background: neutral100,
      error: error,
      onPrimary: neutral0,
      onSecondary: neutral0,
      onTertiary: neutral0,
      onSurface: neutral50,
      onBackground: neutral50,
      onError: neutral0,
    ).toScheme;
  }
}
